import { _decorator, Component, Node } from 'cc';
import { TaskCenter } from '../../../Frame/interface/TaskCenter';
import { GModule } from '../../../Frame/interface/GModule';
const { ccclass, property } = _decorator;

@ccclass('GameMgr')
export class GameMgr extends Component implements TaskCenter  {
    loadedGModules: GModule[] = [];
    /**注册模块 */
    register(module: GModule) {
        module.onload();
        this.loadedGModules.push(module);
    }

    /**注销模块 */
    unregister(module: GModule) {
        module.unload();
        let index = this.loadedGModules.indexOf(module);
        if (index !== -1) {
            this.loadedGModules.splice(index, 1);
        }
    }
    start() {
    }
    update(deltaTime: number) {
        this.loadedGModules?.forEach(Gmodule => {
            Gmodule.update(deltaTime);
        });
    }
}

